import ctypes
import sys

def isAdminMode() -> bool:
    '''Check if the application is running with administrator privileges'''
    try:
        return ctypes.windll.shell32.IsUserAnAdmin() != 0
    except Exception:
        return False
    
def restartAsAdmin() -> None:
    '''Restart the application with administrator privileges'''
    ctypes.windll.shell32.ShellExecuteW(
        None,
        'runas',  # Run as administrator
        sys.executable,
        ' '.join(sys.argv),
        None,
        1
    )

    exit(0)

def restartWithoutAdmin() -> None:
    '''Restart the application without administrator privileges'''
    argv = sys.argv
    argv.append('--island-no-admin')  # Add flag to skip admin check

    ctypes.windll.shell32.ShellExecuteW(
        None,
        'open',
        sys.executable,
        ' '.join(argv),
        None,
        1
    )

    exit(0)